package com.gjy.quartz.trigger;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-08-30 15:43:58
 */
public class DailyTimeTriggerTest {

    public static void main(String[] args) throws SchedulerException {
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        Map<String, String> map = new HashMap<>();
        map.put("name", "dailyTime");
        map.put("time", LocalDateTime.now().toString());

        JobDetail job = JobBuilder.newJob(TriggerJob.class)
                .usingJobData(new JobDataMap(map))
                .withIdentity("dailyTime", "triggerJob")
                .build();

        Trigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("dailyTime", "triggerTrigger")
                .startNow()
                .withSchedule(DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule()
                        .startingDailyAt(TimeOfDay.hourAndMinuteOfDay(16, 13))
                        .endingDailyAt(TimeOfDay.hourAndMinuteOfDay(16, 14))
                        .withInterval(10, DateBuilder.IntervalUnit.SECOND)
                )
                .build();

        scheduler.scheduleJob(job, trigger);
        scheduler.start();
    }

}
